﻿<?php 
include_once("../function.php");
//print_r($_COOKIE);

$sql="select * from ts_product where ifshow=1 and snums>0";
if(isset($_GET['sub']))
{
	extract($_GET);//$uname
	if(!empty($uname))
	{
		$sql=" select * from ts_product where ifshow=1 and pname like '%$uname%'";
   }
}
if(isset($_GET['pc_id']))
{
	extract($_GET);//$uname
	if(!empty($pc_id))
	{
		$sql=" select * from ts_product where ifshow=1 and p_c_id=$pc_id";
   }
}
//$sql="select * from ts_product";
$res=mysqli_query($link,$sql);
if(is_object($res))
{
	if(mysqli_num_rows($res)>0)
	{
		$arr=array();
		while(($list=mysqli_fetch_assoc($res))!=false)
		{
			$arr[]=$list;
		}
		//print_r($arr);
	}
}
$res=mysqli_query($link,$sql);
if(is_object($res))
{
		$total=mysqli_num_rows($res);
		$num=8;
		$page=1;
		$pages=ceil($total/$num);
        if(isset($_GET['page']))
		{
			$page=$_GET['page'];
		}
		$start=($page-1)*$num;
		$sql.=" order by pid desc limit $start,$num";	
		
}
		$res=mysqli_query($link,$sql);
		if(is_object($res))
		{
			if(mysqli_num_rows($res)>0)
			{
				$sys=array();
				while(($list=mysqli_fetch_assoc($res))!=false)
				{
					$sys[]=$list;
				}
					//print_r($sys);
			}
		}
	
?>
<!doctype html>
<html>
 <head>
 <?php $sql="select * from ts_sysconfig";
		$res=mysqli_query($link,$sql);
		if(is_object($res))
		{
			if(mysqli_num_rows($res)>0)
			{
				$qq=array();
				while(($list=mysqli_fetch_assoc($res))!=false)
				{
					$qq[]=$list;
				}
			}
		}
		foreach($qq as $v)
		{if($v['sys_name']=='title'){?>
			  <title><?=$v['sys_val']?></title>
			  <?php }else{?>
			  <meta name="<?=$v['sys_name']?>" content="<?=$v['sys_val']?>">
		<?php }}
 ?>
  
  <meta charset="utf-8"/>
  
  
  <style>
     *{margin:0px;padding:0px;}
#big{
	 width:100%;
	 height:200px;
	 border:0px solid red;
	 margin:0px auto;
	}
ul{
	 list-style-type:none;
	}
li{
	float:left;
	margin-left:15px;
	font-size:1.3em;
	color:#a5a5a5;
	}
span{
	float:right;
	}
.p0{
	margin-left:20px;
	}
.xs{
	margin-left:20px;
	height:50px;
	width:100%;
	border:0px solid red;
	}
.xc1{
	font-size:2em;
	margin-right:50px;
	}

	#dh{background:#1F81B0;width:100%;height:50px;}
	ul{list-style-type:none;height:50px;}

	ul li{float:left;margin:10px;margin-left:30px;line-height:30px;color:white;}

	li a{text-decoration:none;color:white;}

#ww{border:0px solid red;}
#w2 li{color:black;font-size:15px;}
#fl #dl{
		border:0px solid red;
		list-style-type:none;
		height:40px;
		line-height:40px;
		background:#fafafa;
		position:relative;
	  }
	 
		li a:link,li a:visited{
		color:white;
		text-decoration:none;} 
		
		li a:hover,li a:active{
		color:white;
		text-decoration:none;
		}
		#fei li a:link,#fei li a:visited{text-decoration:none;color:black;font-size:0.8em;}
		#fei li a:hover,#fei li a:active{text-decoration:underline;}
		
#middle{
		width:100%;
		border:0px solid red;
		margin:0px 0px;
		}
.ml{
	width:275px;
	height:430px;
	border:0px solid #f1f1f1;
	float:left;
	margin:35px 50px;
	margin-left:82px;
	}
.nl{margin-top:10px;
	width:123px;
	height:40px;
	border:0px solid red; 
	margin-left:80px;
	/*background-image:url( "../css2/img/ljgm.png");*/
	background-repeat:no-repeat;
	background-position:center center;
	}
.m{
	width:275px;
	height:270px;
	border:0px solid red;
	
	/*background-image:url("./3.png"  "../css2/img/xc.png" );*/
	background-repeat:no-repeat;
	background-position:center center;
	}	
.sl{
	
	margin-top:20px;
	border:0px solid red;
	text-align:center;
	margin-left:10px;
	}
	.s2{width:75px;border:0px solid red;margin-top:10px;margin-left:110px;}
.ml:hover{
		box-shadow:5px 5px 5px #9bc043;
	}
a{text-decoration:none;color:black;}
td a:link,td a:visited{color:white;}
td a:hover,td a:active{color:yellow;}
#xyy{
	width:100%;
	height:40px;
	border:0px solid red;
	}
#db{
	width:100%;
	height:50px;
	border:0px solid blue;
	line-height:50px;
	}
  p{
	margin-left:43%;
	font-size:15px;
	}
#jy{
	width:100%;
	height:50px;
	border:0px solid red;
	}
.p1{
	margin-left:40%;font-size:10px;
	}
.p3{
	float:right;
	margin-right:15px;
	display:inline-block;
	}
#rl{
	width:100%;
	height:10px;
	border:0px solid blue;
	}
	.dd{width:100%;height:40px;border:0px solid red;line-height:40px;}
	.sy{float:left;margin-left:20px;}
	</style>
 </head>

 <body>
 <form action="index.php" method="get">
<div id="big">
		<div class="dd">
				<span class="sy"><a href="./index.php">网站首页</a></span>
				<span class="sy"><a href="./user_order.php">用户中心</a></span>
				<?php if(isset($_COOKIE["username"])){?>
				<span class="sy"><a href="./shopcar.php">我的购物车(0)</a></span>
				<span class="sy"><a href="./user_order.php">我的订单(0)</a></span>
				<?php }?>
				<span>
					<?php if(!isset($_COOKIE["username"])){ ?>
					
					<a href="./login.php">登录</a>|
					<a href="./regist.php">免费注册</a>
					
					<?php }else{?>
					<font size=3 color="#ababab">您好！<?=$_COOKIE["username"]?>，<b>欢迎来到欣才商城！</b>|
					<a href="./out2.php">退出</a></font>
					
					<?php }?>
				</span>
					
		</div>

		<hr color="#efefef"/>
		<div class="xs">
			<p class="p0"><font color="blue" class="xc1">欣才&nbsp;</font><font size="6">商城</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			
			<input type="text" name="uname" value=""/>
			<input type="submit" name="sub" value="搜索"/></p>
			
		</div>

			<div id="dh">
			<ul id="dl">
				<li><a href="./index.php">首页</a></li>
				<li>|</li>
				<li><a href="./index.php">商城</a></li>
				<li>|</li>
				<li><a href="./news.php?cid='32'">新闻</a></li>
				<li>|</li>
				<li><a href="">活动</a></li>
				<li>|</li>
				<li><a href="">论坛</a></li>
			</ul>
			</div>
			
		<div id="fl">
		<?php $sql="select * from ts_product_cate";
			$res=mysqli_query($link,$sql);
			if(is_object($res))
			{
				if(mysqli_num_rows($res)>0)
				{
					$qq=array();
					while(($list=mysqli_fetch_assoc($res))!=false)
					{
						$qq[]=$list;
					}
				}
			}?>
			<ul id="fei">
			<li><a href="">分类:</a></li>
			<li><a href="./index.php" >全部</a></li>
		<?php foreach($qq as $k){?>
		
			 <li><a href="./index.php?pc_id=<?=$k['pc_id']?>"><?=$k['pc_name']?></a></li>
		<?php }?>
				</div>
			</ul>
		</div><hr/>

		<div id="middle">
		
		<?php if(isset($sys)){foreach($sys as $v){?>
		    <div class="ml">
				<div class="m">
					<a href="./xqy.php?pid=<?=$v['pid']?>"><img src="../<?=$v['thumb']?>" width="275px" height="290px"> 
				</div>
				<div class="m1 sl"><b><a href="./xqy.php?pid=<?=$v['pid']?>"><?=$v["pname"]?></a></b></div>
				<div class="m1 s2"><a href=""><?=$v["price"]?></a></div>
				<div class="ml nl">
					<a href='xqy.php?pid=<?=$v["pid"]?>'><img src="../img/ljgm.png"></a>
				</div>
			</div>
		<?php }}?>
				<div style="clear:both"></div>
			</div>
		<div>
		<div style="width:180px;height:20px;border:0px solid blue;float:right;font-size:15px;"><?php if(isset($_GET['sub'])){if(isset($page)&&$page>1){?>
			<a href="index.php?page=<?=$page-1?>&uname=<?=$_GET['uname']?>&sub=<?$_GET['sub']?>"上一页</a>
			<?php }?>

			<a>第<?=isset($page)?$page:1?>页/共<?=isset($pages)?$pages:1?>页</a>

			<?php if(isset($page)&&$page<$pages){?>

			<a href="index.php?page=<?=$page+1?>&uname=<?=$_GET['uname']?>&sub=<?$_GET['sub']?>">下一页</a>

			<?php }}
			else{if(isset($page)&&$page>1){?>
			<a href="index.php?page=<?=$page-1?>">上一页</a>
			<?php } ?>
			
			第<?=isset($page)?$page:1?>页/共<?=isset($pages)?$pages:1?>页
			<?php if(isset($page)&&$page<$pages){?><a href="index.php?page=<?=$page+1?>">下一页</a>
		<?php }}?>
		</div>
	<div id="ww">
		<ul id="w2">
				<span style="float:left;margin-top:20px;"><li>7日免费退货</li>
				<li>15日免费更换</li>
				<li>全场包邮</li>
				<li>全国范围均可配送</li></span>
				<span style="float:right;width:400px;border:0px solid red;margin-right:-150px;margin-top:20px;">
				<li>支付方式</li>
				<li>|</li>
				<li>配送说明</li>
				<li>|</li>
				<li>售后服务</li><span>
		</ul>
	</div>		
	<div style="clear:both;width:100%;height:150px;border:0px solid yellow;"><hr color="#e5e5e5"/>
		<?php $sql="select * from ts_news_cate where level=1";
			  $res=mysqli_query($link,$sql);
			  if(is_object($res))
			  {
				  if(mysqli_num_rows($res)>0)
				  {
					$arr=array();
					while(($one=mysqli_fetch_assoc($res))!=false)
					  {
						  $arr[]=$one;
					  }
				  }	?>
					
					<?php foreach($arr as $v)
					{?>
						<div style="float:left;margin-left:250px;border:0px solid red;font-size:16px;margin-top:7px;"><div style="border:px solid blue;font-size:19px;margin-left:-8px;"><?=$v["cname"]?></div>
						<?php $sql="select * from ts_news_cate where fid=$v[cid]";
						$res=mysqli_query($link,$sql);
						if(is_object($res))
						 {
							$arr2=array();
							while(($one1=mysqli_fetch_assoc($res))!=false)
							 {
								$arr2[]=$one1;
							 }
							foreach($arr2 as $vo)
							 {?>
								<div><a href="news.php?cid=<?=$vo['cid']?>"><?=$vo["cname"]?></a></div>
							 <?php }
						 }?>
						</div>
				<?php }
					
			  }
		?>
	
	</div>
		<hr color="#e5e5e5"/>	
	<div id="db">
		<p>关于我们|法律声明|工作机会|联系我们</p>
	</div>

	<div id="jy">
		<p class="p1">Copyright@2013 Thinksite Co.Let night reserved 经营许可证编号：苏A-12345678</p>
	</div>
</div>
</form>
 </body>
</html>